-module(factest).
-export([fac/1,fac_tail/1]).
    
fac(0) ->
    1;
fac(N) ->
    N * fac(N-1).


fac_tail(N) ->
    fac_t(N-1,N).
fac_t(1,Acc) ->
    Acc;
fac_t(N,M) ->
    fac_t(N-1,N*M).
